﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

public partial class quickLMS : System.Web.UI.MasterPage
{
    public HtmlGenericControl MasterBody
    {
        get
        {
            return MasterBodyControl;
        }
        set
        {
            MasterBodyControl = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
		HtmlMeta hm = new HtmlMeta();
        hm.HttpEquiv = "X-UA-Compatible";
        hm.Content = "IE=EmulateIE7";
        Page.Header.Controls.AddAt(0, hm);
    }

    protected void ModifyMenu(object sender, EventArgs e)
    {
        if (Roles.IsUserInRole(Membership.GetUser().UserName, "Instructor") && ((Menu)sender).Items.Count > 1)
        {
            if (((Menu)sender).Items[1].ChildItems.Count > 3)
            {
                ((Menu)sender).Items[1].ChildItems.RemoveAt(1);
                ((Menu)sender).Items[1].ChildItems.RemoveAt(1);
            }
        }
        if (Roles.IsUserInRole(Membership.GetUser().UserName, "Student"))
            ((Menu)sender).Visible = false;
    }

    protected void lnkLogout_Click(object sender, EventArgs e)
    {
        //forget the user
        if (Request.Cookies["userID"] != null)
        {
            Request.Cookies["userID"].Expires = DateTime.UtcNow.AddDays(-1d);
            Response.Cookies["userID"].Value = "";
            Response.Cookies.Add(Request.Cookies["userID"]);
        }
        FormsAuthentication.SignOut();
        Response.Redirect("~/default.aspx", false);
    }
}
